<template>
  <div style="height: 100%;">
    <!--部门定义-->
    <div class="flex" style="height: 100%;">
      <span></span>
    </div>

  </div>
</template>

<script>

// 获取登录接口
import loginApi from "@/api/login";
import cfg from '@/config/config'

export default {
  components: {

  },
  name: '',
  data() {
    return {
      // url: cfg.apiUrl + 'api/login/ssoLogin'
    }
  },
  beforeMount() {

  },
  mounted() {
    // var query=this.$route.query;
    // 读取配置文件
    // cfg.getUrl()
    this.submit();
  },
  methods: {
    async submit() {
      let param = {
        username: this.$route.query.domain,
        activeId: 2
      };
      //调用后台方法
      let res = await loginApi.userLogin2(param);
      if (res.data.success) {
        console.log(res.data.result.menuList[0].children[0].path);
        localStorage.setItem("openKeys", res.data.result.menuList[0].path);
        this.$store.commit('addSelectedKeys',res.data.result.menuList[0].children[0].path);
        localStorage.setItem("selectedKeys", JSON.stringify(res.data.result.menuList[0].children[0].path))
        localStorage.setItem("user", JSON.stringify(res.data.result.user));
        this.$store.state.user.userNO = res.data.result.userNO;
        this.$store.state.user.userName = res.data.result.userName;
        this.$store.state.menuList = res.data.result.menuList;
        this.$nextTick(()=>{
          this.$router.replace(`/${res.data.result.menuList[0].children[0].path}`);
        })
      } else {
        this.$router.push({
          path:"/singleError",
          query:{
            ssoError:res.data.message=='程序内部错误'?'SSO登陆失败':res.data.message
          }
        });
      }
    }
  }
}
</script>

<style scoped>

</style>

